﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DataGridApplication.ScrumMagicDataSetTableAdapters;
using System.Data;

namespace DataGridApplication
{
  public class TaskDataProvider
  {
    private TaskTableAdapter adapter;

    private ScrumMagicDataSet dataset;

    public TaskDataProvider()
    {
      dataset = new ScrumMagicDataSet();
      adapter = new TaskTableAdapter();
      adapter.Fill(dataset.Task);

      dataset.Task.TaskRowChanged +=
        new ScrumMagicDataSet.TaskRowChangeEventHandler(TaskRowModified);
      dataset.Task.TaskRowDeleted +=
          new ScrumMagicDataSet.TaskRowChangeEventHandler(TaskRowModified);

    }

    public DataView GetTask()
    {
        return dataset.Task.DefaultView;
    }

    void TaskRowModified(object sender, ScrumMagicDataSet.TaskRowChangeEvent e)
    {
      adapter.Update(dataset.Task);
    }
  }
}
